<script setup lang="tsx">
import { onMounted, ref } from 'vue'
import { HttpCodeEnum } from '@packages/share/enums'
import { getSocialMoreInfoAPI } from '@/api/search/index'
import { More } from '@element-plus/icons-vue'
const props = defineProps({
  id: { type: String, required: true }
})
const list = ref([])
const getInfo = (id: string) => {
  getSocialMoreInfoAPI(id).then((res) => {
    let { code, rows } = res.data
    if (code === HttpCodeEnum.SUCCESS) {
      console.log(rows)
      list.value = rows
    }
  })
}
onMounted(() => {
  getInfo(props.id)
})
</script>
<template>
  <div class="list-item" v-for="item in list" :key="item.id">
    <div class="title text-ellipsis">
      <span>{{ item.title }}</span>
      <el-icon class="icons"><More /></el-icon>
    </div>
    <div class="summary-con">
      <img src="@/assets/logo/logo.png" />
      <div class="summery text-ellipsis">
        {{ item.summary }}
      </div>
    </div>
    <div class="content">
      {{ item.content }}
    </div>
    <el-link type="info" :href="item.href" target="_blank">{{ item.href }}</el-link>
    <div>
      <el-tag v-for="(val, key) in item.tags" :key="key" class="tags" type="info" round>{{
        `${key}:${val}`
      }}</el-tag>
    </div>
  </div>
</template>
<style scoped lang="scss">
.text-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item {
  cursor: pointer;
  margin-bottom: 3.125rem;
  &:last-child {
    margin-bottom: 0.625rem;
  }
}
.title {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 1.25rem;
  .icons {
    transform: rotate(-90deg);
  }
}
.summary-con {
  display: flex;
  align-items: center;
  img {
    margin-right: 1.25rem;
    width: 1.5625rem;
    height: 1.5625rem;
  }
  .summery {
    flex: 1;
    padding: 0.625rem;
    background-color: var(--el-bg-color-page);
  }
}
.content {
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-overflow: ellipsis;
}
.tags {
  margin-top: 1.25rem;
  margin-right: 0.625rem;
}
</style>
